﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Base.Master" AutoEventWireup="true"
    CodeBehind="MenuManager.aspx.cs" Inherits="QuickLifeHall.ERP.Pages.SystemBase.Menu.MenuManager" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#tt").tree({
                loader: function (param, success, error) {
                    var parentId = 0;
                    //var selectedNode = $('#tt').tree('getSelected');
                    if (param) parentId = param.id;

                    QuickLifeHall.Facade.SystemBase.Menu.GetChildrenMenu(parentId, function (result) {
                        if (result && result.error == null) {
                            success(result.value);
                        }
                        else {
                            alert(result.error.Message);
                            error();
                        }
                    });
                }
            });
        });

        function _addRoot() {
            showWindow({
                title: '添加用户',
                url: '/pages/systembase/menu/MenuAddAndEdit.aspx',
                width: 500,
                height: 300,
                param:null,
                onClose: function () { _search(); }
            });
        }

        function _addChild() {
            var selectedNode = $("#tt").tree("getSelected");
            if(!selectedNode){
                $.messager.alert("提示", "请先选中一个一级菜单");
                return;
            }

            var menuEntity = selectedNode.attributes.getValue("entity");

            if (menuEntity.ParentID != "0") {
                $.messager.alert("提示", "请选择第一级菜单");
                return;
            }

            showWindow({
                title: '添加用户',
                url: '/pages/systembase/menu/MenuAddAndEdit.aspx',
                width: 500,
                height: 300,
                param: menuEntity,
                onClose: function () { _search(); }
            });
        }

        function _edit() {

        }

        function _delete() {

        }

        function _search() {
            $("#tt").tree("reload");
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="tb" class="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="true"
            onclick="_addRoot()">新增根菜单</a><a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="true"
            onclick="_addChild()">新增子菜单</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit"
                plain="true" onclick="_edit()">编辑</a> <a href="javascript:void(0)" class="easyui-linkbutton"
                    iconcls="icon-no" plain="true" onclick="_delete()">删除</a>
    </div>
    <div style="overflow: auto; height: 500px; border: solid 1px #ccc; padding:5px 10px;">
        <ul id="tt">
        </ul>
    </div>
</asp:Content>
